package logic

import (
	"context"
	"huiyun/model/mysql"

	"huiyun/huiyunrpc/huiyunrpc"
	"huiyun/huiyunrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type SportAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewSportAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SportAddLogic {
	return &SportAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 活动发布
func (l *SportAddLogic) SportAdd(in *huiyunrpc.SportAddRequest) (*huiyunrpc.SportAddResponse, error) {
	// todo: add your logic here and delete this line

	sport := mysql.Sport{
		Image:     in.Image,
		Name:      in.Name,
		Writer:    in.Writer,
		ClassName: in.ClassName,
		Num:       in.Num,
		UserId:    in.UserId,
	}
	mysql.DB.Debug().Create(&sport)

	return &huiyunrpc.SportAddResponse{
		Id: int64(sport.ID),
	}, nil
}
